home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / MYMUD21.ZIP / MMUD21.ZIP / SOURCE / SOURCE.ZIP / MACRO.PAS < prev    next >
Pascal/Delphi Source File  |  1995-01-21  |  3KB  |  136 lines

  1. {$I COPYRGHT.INC}
  2.  
  3. (*---------------------------------------------------------------------------*
  4.    This unit contains all the macro support routines
  5.  *---------------------------------------------------------------------------*)
  6.  
  7. Unit Macro;
  8. Interface
  9. Uses Header,
  10.      bin_DB,
  11.      MyIO,
  12.      Multi,
  13.      Misc,
  14.      LowLevel,
  15.      BoolExpr;
  16.  
  17. Procedure Macro_Let(Current : ContextType;InpStr : String);
  18. Procedure Macro_Random(Current : ContextType;InpStr : String);
  19. Procedure Macro_ShowFile(Current : ContextType; InpStr : String);
  20. Procedure Macro_SayAll(Current : ContextType; InpStr : String);
  21. Procedure Macro_SayUser(Current : ContextType; InpStr : String);
  22. Procedure Macro_Pennies(Current : ContextType;InpStr : String);
  23.  
  24. Implementation
  25.  
  26. Procedure Macro_Let(Current : ContextType;InpStr : String);
  27. Var ObjNr : Integer;
  28.     VarNr : Byte;
  29.     Value : String[20];
  30.     VarStr: String[20];
  31. Begin
  32. If InpStr=''
  33.    Then Begin
  34.         My_WriteLn('Syntax error: &LET <Var>=<ObjNr>');
  35.         Exit;
  36.         End;
  37.  
  38. Current.DB.ReadObj(Current.Player);
  39.  
  40. If Not SplitCommand(InpStr,VarStr,Value)
  41.    Then Begin
  42.         VarNr:=Str2Nr(VarStr);
  43.         If VarNr=0
  44.            Then My_WriteLn('<Var> should be between 1 and 9')
  45.            Else Current.DB.ObjRec.Storage[VarNr]:=-1;
  46.         Exit;
  47.         End;
  48.  
  49. VarNr:=Str2Nr(VarStr);
  50. ObjNr:=Str2ObjNr(Current,Value);
  51. If ObjNr=NOTHING
  52.    Then ObjNr:=Str2Nr(Value);
  53.  
  54. Lock('Storage');
  55. Current.DB.ReadObj(Current.Player);
  56. Current.DB.ObjRec.Storage[VarNr]:=ObjNr;
  57. Current.DB.UpdateObj(Current.Player);
  58. Unlock;
  59. End;
  60.  
  61. Procedure Macro_Random(Current : ContextType;InpStr : String);
  62. Var BNr   : Integer;
  63.     LNr   : Integer;
  64.     Break : String[20];
  65.     Limit : String[20];
  66. Begin
  67. If (InpStr='')
  68.    Then Begin
  69.         My_WriteLn('Syntax error: &RANDOM <Limit>[=<Breakpoint>]');
  70.         Exit;
  71.         End;
  72.  
  73. If Not SplitCommand(InpStr,Limit,Break)
  74.    Then Begin
  75.         Current.DB.ReadObj(Current.Player);
  76.         Current.DB.ObjRec.Storage[0]:=Random(Str2Nr(InpStr));
  77.         Exit;
  78.         End;
  79.  
  80.  
  81. BNr:=Str2Nr(Break);
  82. LNr:=Str2Nr(Limit);
  83. If ((BNr*LNr)=0) Or
  84.    (BNr>LNr)
  85.    Then Begin
  86.         My_WriteLn('Break and limit value should be >0 and Limit>Break');
  87.         Exit;
  88.         End;
  89. If Random(LNr)>BNr
  90.    Then MacroString:='';
  91. End;
  92.  
  93. Procedure Macro_ShowFile(Current : ContextType; InpStr : String);
  94. Begin
  95. InpStr:=ChangePathTo(InpStr,TextPath);
  96.  
  97. If Not ExistFile(InpStr)
  98.    Then Begin
  99.         MacroString:='';
  100.         Exit;
  101.         End;
  102. ShowFile(InpStr);
  103. End;
  104.  
  105. Procedure Macro_Pennies(Current : ContextType;InpStr : String);
  106. Var Gain : Integer;
  107.     Err  : Integer;
  108. Begin
  109. If InpStr=''
  110.    Then Begin
  111.         MacroString:='';
  112.         Exit;
  113.         End;
  114. Val(InpStr,Gain,Err);
  115. If Err<>0 Then Gain:=0;
  116. Lock('Updating pennies');
  117. Current.DB.ReadObj(Current.Player);
  118. Inc(Current.DB.ObjRec.Pennies,Gain);
  119. Current.DB.UpdateObj(Current.Player);
  120. Unlock;
  121. End;
  122.  
  123. Procedure Macro_SayUser(Current : ContextType; InpStr : String);
  124. Begin
  125. If InpStr<>''
  126.    Then My_WriteLn(InpStr);
  127. End;
  128.  
  129. Procedure Macro_SayAll(Current : ContextType; InpStr : String);
  130. Begin
  131. If InpStr<>''
  132.    Then SayToAllHere(Current,InpStr);
  133. End;
  134.  
  135. End.
  136.